<template>
	<view>
		<view>
			<view v-for="(item,index) in owners" :key="index" class="content bg-white margin-bottom margin-right-xs radius margin-left-xs padding">
				<view class="flex padding-bottom-xs solid-bottom justify-between">
					<view>{{item.name}}请求成为您的家庭成员</view>
				</view>
				
				<view class="solid-top flex justify-around margin-top padding-top-sm padding-bottom-sm">
					<button  class="cu-btn sm bg-green " @click="_deleteOwnerMember(item)">同意</button>
					<button  class="cu-btn sm bg-red " @click="_deleteOwnerMember(item)">拒绝</button>
				</view>
			</view>
		</view>
<!-- 		<view v-else>
			<no-data-page></no-data-page>
		</view> -->
		<view class="button_up_blank"></view>


		
		<view class="cu-modal" :class="delOwnerMemberFlag==true?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">温馨提示</view>
					<view class="action" @tap="_cancleCall()">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl">
					您确认拒绝？
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action margin-0 flex-sub  solid-left" @tap="_cancleDeleteOwnerMember()">取消</view>
					<view class="action margin-0 flex-sub text-green solid-left" @tap="_doDeleteOwnerMember()">确认</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import context from '../../lib/java110/Java110Context.js';
	const constant = context.constant;
	import noDataPage from '@/components/no-data-page/no-data-page.vue';
	
	import {deleteOwnerMember} from '../../api/owner/ownerApi.js'
	export default {
		data() {
			return {
				owners: [],
				delOwnerMemberFlag:false,
				page: 1,
				totalPage: 0,
				loading: false,
				communityId: '1111',
				ownerId: '',
				curOwnerMember:{},
				ownerTypeCd: '1001',
			};
		},
		components: {
			noDataPage
		},
		onLoad(option) {
			this.homeData()
			
		},
		// onShow: function() {
		// 	this._initData();
			
		// },

		methods: {
			homeData(){
				let owner = uni.getStorageSync("commonUser");
				this.ownerId = owner.id
				uni.request({
					url: constant.url.shenpi,
					header: context.getHeaders(),
					method: "GET",
					data: {
						proprietorId: this.ownerId,

					},
					success: (resData) => {
						this.ownerData = resData
						// this.ownerInfo()
						console.log("res申请成为家庭成员", this.ownerData)
					}
				})
			},
			// _initData:function(){
			// 	let that = this;
			// 	that.owners = [];
			// 	// 使用 require.context查询并把符合条件的结果文件名加入到一个键-值对形式的对象 requireComponent中
			// 	context.getOwner(function(_owner) {
			// 		that.communityId = _owner.communityId;
			// 		that.ownerId = _owner.memberId;
			// 		that.ownerTypeCd = _owner.ownerTypeCd;
			// 		that.getTable(1);
			// 	});
			// },
			// getTable: function(page, override) {
			// 	let that = this;
			// 	this.loading = true;
			// 	let _paramIn = {
			// 		"communityId": that.communityId,
			// 		"ownerId": that.ownerId
			// 	};
				// context.request({
				// 	url: constant.url.queryOwnerMembers,
				// 	header: context.getHeaders(),
				// 	method: "GET",
				// 	data: _paramIn,
				// 	success: function(res) {
				// 		if (res.statusCode == 200) {
				// 			let _owners = res.data.owners;
				// 			that.owners = _owners;
				// 			that.loading = false;
				// 		}
				// 	},
				// 	fail: function(e) {
				// 		wx.showToast({
				// 			title: "服务器异常了",
				// 			icon: 'none',
				// 			duration: 2000
				// 		})
				// 	}
				// })
			// },
			goAdd: function(e) {
				uni.navigateTo({
					url: "/pages/family/family"
				})
				// this.vc.navigateTo({
				// 	url: "/pages/family/family"
				// })
			},
			family_home:function(){
				uni.navigateTo({
					url: "../family/familyMumber"
				})
			},
			_deleteOwnerMember:function(item){
				this.delOwnerMemberFlag = true;
				this.curOwnerMember = item;
			},
			_cancleDeleteOwnerMember:function(item){
				this.delOwnerMemberFlag = false;
			},
			_doDeleteOwnerMember:function(){
				let that = this;
				this.curOwnerMember.communityId = this.communityId;
				deleteOwnerMember(this.curOwnerMember)
				.then((res)=>{
					uni.showToast({
						icon:'none',
						title:'删除成功'
					});
					that._cancleDeleteOwnerMember();
					that._initData();
				},(err)=>{
					uni.showToast({
						icon:'none',
						title:err
					});
					that._cancleDeleteOwnerMember();
				})
			}
		}
	};
</script>
<style scoped lang="scss">
	.content{
		margin: 20rpx 30rpx 20rpx 30rpx;
		border-radius: 30rpx;
	}
	.ppf_item {
		padding: 0rpx 0rpx 0rpx 0rpx;
	}
	.btn-group{
		height: 100%;
		button{
			width: 100%;
			height: 70rpx;
			margin-top: 15rpx;
			border-radius: 30rpx;
		}
	}
	.block__title {
		margin: 0;
		font-weight: 400;
		font-size: 14px;
		color: rgba(69, 90, 100, .6);
		padding: 40rpx 30rpx 20rpx;
	}

	.button_up_blank {
		height: 100rpx;
	}

	.cu-btn.lgplus {
		padding: 0 20px;
		font-size: 18px;
		height: 100upx;

	}

	.cu-btn.sharp {
		border-radius: 0upx;
	}

	.line-height {
		line-height: 100upx;
	}
</style>
